package com.margo.project.web.introduction;

import org.aopalliance.intercept.MethodInvocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.IntroductionInterceptor;

public class MargoIntroductionInterceptor implements IntroductionInterceptor, IMargoGirl {

	Logger logger=LoggerFactory.getLogger(MargoIntroductionInterceptor.class);
	
	@Override
	public Object invoke(MethodInvocation invocation) throws Throwable {
		if (implementsInterface(invocation.getMethod().getDeclaringClass())) {
			logger.info("我是引介增强的方法体~~~invoke");
			return invocation.getMethod().invoke(this, invocation.getArguments());
		}
		return invocation.proceed();
	}

	@Override
	public boolean implementsInterface(Class<?> clazz) {
		return clazz.isAssignableFrom(IMargoGirl.class);
	}

	@Override
	public boolean doOther() {
		logger.info("doOther.......");
		return true;

	}

}
